<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>Right</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="/resources/favicon.ico">
    <link rel="stylesheet" href="resources/layui/css/layui.css" th:href="@{/resources/layui/css/layui.css}" media="all"/>
    <link rel="stylesheet" th:href="@{/resources/css/public.css}" media="all"/>
    <link rel="stylesheet" th:href="@{/resources/layui_ext/dtree/dtree.css}" media="all"/>
    <link rel="stylesheet" th:href="@{/resources/layui_ext/dtree/font/dtreefont.css}" media="all"/>
    <style>
        input#search_provideridTree_select_input_id {
            border-radius: 10px;
            height: 30px;
            margin-top: 4px;
        }
        input#provideridTree_select_input_id {
            border-radius: 10px;
            height: 30px;
            margin-top: 4px;
        }
        input#leaderprovideridTree_select_input_id {
            border-radius: 10px;
            height: 30px;
            margin-top: 4px;
        }
        input.layui-input.layui-unselect {
            border-radius: 10px;
            height: 30px;
            margin-top: 4px;
        }
    </style>
</head>
<body>
<!--查询条件-->
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 15px;">
    <legend>搜索条件</legend>
</fieldset>
<form action="" method="post" id="searchFrm" lay-filter="searchFrm" class="layui-form">
    <div class="layui-form-item">

        <div class="layui-inline">
            <label class="layui-form-label">商品名称</label>
            <div class="layui-input-inline">
                <input type="text" name="goodsname" id="goodsname" class="layui-input input-radius"
                       placeholder="请输入商品名称">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">商品描述</label>
            <div class="layui-input-inline">
                <input type="text" name="description" id="description" class="layui-input input-radius"
                       placeholder="请输入商品描述">
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">订单状态</label>
            <div class="layui-input-inline">
                <select  name="state" id="state">
                    <option value="">请选择</option>
                    <option value="1">待发货</option>
                    <option value="2">已发货</option>
                    <option value="3">订单完成</option>
                    <option value="4">已租赁</option>
                    <option value="5">归还待确认</option>
                    <option value="6">已归还</option>
                </select>
            </div>
        </div>

        <div class="layui-inline" style="padding-left: 3%">
            <button type="button" class="layui-btn layui-btn-sm layui-btn-radius" lay-submit="" lay-filter="doSearch"><i
                    class="layui-icon layui-icon-search layui-icon-normal"></i>查询
            </button>
            <button type="reset" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-warm"><i
                    class="layui-icon layui-icon-refresh"></i><span>重置</span>
            </button>
        </div>
    </div>
</form>

<!--数据表格-->
<div>
    <table class="layui-hide" id="orderTable" lay-filter="orderTable"></table>
    <div id="orderToolBar" style="display: none">
        <button type="button" lay-event="add" shiro:hasPermission="order:create" class="layui-btn layui-btn-sm layui-btn-normal layui-btn-radius">
            <i class="layui-icon layui-icon-add-1"></i>添加订单
        </button>
    </div>
    <div id="orderRowBar" style="display: none;">

    </div>
</div>

<!--添加和修改弹出层-->
<div id="addOrUpdateDiv" style="display: none;padding: 10px;padding-right: 5%">
    <form action="" method="post" class="layui-form" id="dataFrm" lay-filter="dataFrm">
        <div class="layui-col-md12 layui-col-xs12">
            <div class="layui-row layui-col-space10">
                    <div class="layui-form-item">
                        <label class="layui-form-label">商品名称</label>
                        <div class="layui-input-block">
                            <input type="hidden" name="id">
                            <input type="hidden" name="type" value="租赁">
                            <input type="hidden" name="state" value="4">
                            <input type="text" class="layui-input input-radius" name="goodsname" lay-verify="required" placeholder="请输入商品名称">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">商品产地</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input input-radius" name="produceplace" lay-verify="required" placeholder="请输入商品产地">
                        </div>
                    </div>
            </div>
            <div class="layui-form-item magb0">
                <div class="layui-inline">
                    <label class="layui-form-label">租赁价格</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input input-radius" name="price" lay-verify="required" placeholder="请输入租赁价格">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">商品描述</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input input-radius" name="description" lay-verify="required" placeholder="请输入商品描述">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">租赁天数</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input input-radius" name="num" lay-verify="required" placeholder="请输入租赁天数">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">购买人</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input input-radius" name="username" lay-verify="required" placeholder="请输入购买人">
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block" style="text-align: center;padding-right: 7%">
                <button type="button" class="layui-btn layui-btn-radius" lay-submit="" lay-filter="doSubmit" id="doSubmit"><i
                        class="layui-icon layui-icon-search layui-icon-normal"></i>提交
                </button>
                <button type="reset" class="layui-btn layui-btn-radius layui-btn-warm"><i
                        class="layui-icon layui-icon-refresh"></i><span>重置</span>
                </button>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript" src="/resources/layui/layui.js"></script>
<script type="text/html" id="classActionBar">
    <button type="button" lay-event="Update" shiro:hasPermission="order:update" class="layui-btn layui-btn-xs layui-btn-radius"><i
            class="layui-icon layui-icon-edit"></i>编辑
    </button>
    <button type="button" lay-event="delete" shiro:hasPermission="order:delete" class="layui-btn layui-btn-xs layui-btn-danger layui-btn-radius"><i
            class="layui-icon layui-icon-delete"></i>删除
    </button>
    {{#  if(d.state==2){ }}
    <button type="button" lay-event="update" id="update" shiro:hasPermission="order:confirm" class="layui-btn layui-btn-xs layui-btn-radius"><i
            class="layui-icon layui-icon-edit"></i>确认收货
    </button>
    {{#  } else if (d.state==1) { }}
    <button type="button" lay-event="fahuo" id="fahuo" shiro:hasPermission="order:fahuo" class="layui-btn layui-btn-xs layui-btn-radius"><i
            class="layui-icon layui-icon-ok"></i>发货
    </button>
    {{#  } else if (d.state==3) { }}
    <button type="button" lay-event="tuihuo" id="tuihuo" shiro:hasPermission="order:tuihuo" class="layui-btn layui-btn-danger layui-btn-xs layui-btn-radius"><i
            class="layui-icon layui-icon-delete"></i>退货
    </button>
    {{#  } else if (d.state==4) { }}
    <button type="button" lay-event="return" id="rent" shiro:hasPermission="order:return" class="layui-btn layui-btn-xs layui-btn-danger layui-btn-radius"><i
            class="layui-icon layui-icon-ok"></i>归还
    </button>
    {{#  } else if (d.state==5) { }}
    <button type="button" lay-event="confirmReturn" id="confirmReturn" shiro:hasPermission="order:confirmReturn" class="layui-btn layui-btn-xs  layui-btn-radius"><i
            class="layui-icon layui-icon-ok-circle"></i>确认归还
    </button>
    {{#  } }}
</script>
<script type="text/html" id="repairBar">

    <button type="button" lay-event="repair" shiro:hasPermission="order:repair" class="layui-btn layui-btn-sm  layui-btn-radius"><i
            class="layui-icon layui-icon-util"></i>维护登记
    </button>

</script>
<script type="text/javascript">

    //提升数据表格的作用域，因为底下还有一个reloadTable方法
    var tableIns;

    layui.use(['jquery', 'form', 'layer', 'table','upload'], function () {
        var $ = layui.jquery;
        var form = layui.form;
        var layer = layui.layer;
        var table = layui.table;
        var upload = layui.upload;


        var username = '[[${session.user.name}]]';

        var role = '[[${session.role}]]';
        console.log(role);
        if (role=="[14]"){
            tableIns = table.render({
                elem: "#orderTable",
                title: "订单数据表格",
                url: "/order/loadAllOrder?state=4",
/*
                where:{username:username},
*/
                toolbar: "#orderToolBar",
                page: true,
                height: "full-180",
                cols: [ [
                    {field: 'id', title: 'ID', align: 'center',width:'61'},
                    {field: 'ordernum', title: '订单号', align: 'center',width:'200'},
                    {field: 'goodsname', title: '商品名称', align: 'center',width:'173'},
                    {field: 'way', title: '方式', align: 'center',width:'88'},
                    {field: 'produceplace', title: '商品产地', align: 'center',width:'88'},
                    {field: 'price', title: '销售/租赁价格', align: 'center',width:'120'},
                    {field: 'description', title: '商品描述', align: 'center',width:'393'},
                    {field: 'num', title: '数量/天数', align: 'center',width:'94'},
                    {field: 'state', title: '订单状态', align: 'center',width:'106',templet:function (d) {
                            if(d.state == 1){
                                /*
                                                        $("#update").addClass("layui-btn-disabled").attr("disabled",true);
                                */
                                return '<font color="red">待发货</font>'
                            }else if(d.state == 2){
                                /*
                                                        $("#fahuo").addClass("layui-btn-disabled").attr("disabled",true);
                                */
                                return '<font color="blue">已发货</font>'
                            }else if(d.state == 3){
                                /*         $("#update").addClass("layui-btn-disabled").attr("disabled",true);
                                         $("#fahuo").addClass("layui-btn-disabled").attr("disabled",true);*/
                                return '<font color="green">订单完成</font>'
                            }else if(d.state == 4){
                                return '<font color="green">已租赁</font>'
                            }else if (d.state == 5){
                                return '<font color="red">归还待确认</font>'

                            }else if(d.state == 6){
                                return '<font color="green">已归还</font>'
                            }else if(d.state == 7){
                                return '<font color="blue">退货申请</font>'
                            }else if (d.state == 8){
                                return '<font color="green">已退货</font>'

                            }else if(d.state == 9){
                                return '<font color="red">拒绝退货</font>'
                            };
                        }},
                    {field: 'username', title: '购买人', align: 'center',width:'100'},
                    {fixed: 'right', title: '操作', align: 'center',width:'250',templet:'#classActionBar'}
                ] ],
                done: function (data, curr, count) {
                    if (username.indexOf("管理员")==-1  ) {
                        $("[data-field='username']").css('display', 'none'); //关键代码
                    }
                    //不是第一页时，如果当前返回的数据为0那么就返回上一页
                    if (data.data.length == 0 && curr != 1) {
                        tableIns.reload({
                            page: {
                                curr: curr - 1
                            }
                        })
                    }
                }
            });
        }else if(role=="[15]") {
            tableIns = table.render({
                elem: "#orderTable",
                title: "订单数据表格",
                url: "/order/loadAllOrderSale",
                /*
                                where:{username:username},
                */
                toolbar: "#orderToolBar",
                page: true,
                height: "full-180",
                cols: [ [
                    {field: 'id', title: 'ID', align: 'center',width:'61'},
                    {field: 'ordernum', title: '订单号', align: 'center',width:'200'},
                    {field: 'goodsname', title: '商品名称', align: 'center',width:'173'},
                    {field: 'way', title: '方式', align: 'center',width:'88'},
                    {field: 'produceplace', title: '商品产地', align: 'center',width:'88'},
                    {field: 'price', title: '销售/租赁价格', align: 'center',width:'120'},
                    {field: 'description', title: '商品描述', align: 'center',width:'393'},
                    {field: 'num', title: '数量/天数', align: 'center',width:'94'},
                    {field: 'state', title: '订单状态', align: 'center',width:'106',templet:function (d) {
                            if(d.state == 1){
                                /*
                                                        $("#update").addClass("layui-btn-disabled").attr("disabled",true);
                                */
                                return '<font color="red">待发货</font>'
                            }else if(d.state == 2){
                                /*
                                                        $("#fahuo").addClass("layui-btn-disabled").attr("disabled",true);
                                */
                                return '<font color="blue">已发货</font>'
                            }else if(d.state == 3){
                                /*         $("#update").addClass("layui-btn-disabled").attr("disabled",true);
                                         $("#fahuo").addClass("layui-btn-disabled").attr("disabled",true);*/
                                return '<font color="green">订单完成</font>'
                            }else if(d.state == 4){
                                return '<font color="green">已租赁</font>'
                            }else if (d.state == 5){
                                return '<font color="red">归还待确认</font>'

                            }else if(d.state == 6){
                                return '<font color="green">已归还</font>'
                            }else if(d.state == 7){
                                return '<font color="blue">退货申请</font>'
                            }else if (d.state == 8){
                                return '<font color="green">已退货</font>'

                            }else if(d.state == 9){
                                return '<font color="red">拒绝退货</font>'
                            };
                        }},
                    {field: 'username', title: '购买人', align: 'center',width:'100'},
                    {fixed: 'right', title: '操作', align: 'center',width:'180',templet:'#classActionBar'}
                ] ],
                done: function (data, curr, count) {
                    if (username.indexOf("管理员")==-1  ) {
                        $("[data-field='username']").css('display', 'none'); //关键代码
                    }
                    //不是第一页时，如果当前返回的数据为0那么就返回上一页
                    if (data.data.length == 0 && curr != 1) {
                        tableIns.reload({
                            page: {
                                curr: curr - 1
                            }
                        })
                    }
                }
            });
        }
        else if(role=="[16]")
        {
            tableIns = table.render({
                elem: "#orderTable",
                title: "订单数据表格",
                url: "/order/loadAllOrder?state=4",
              /*  where:{username:username},*/
                toolbar: "#orderToolBar",
                page: true,
                height: "full-180",
                cols: [ [
                    {field: 'id', title: 'ID', align: 'center',width:'61'},
                    {field: 'ordernum', title: '订单号', align: 'center',width:'200'},
                    {field: 'goodsname', title: '器材名称', align: 'center',width:'173'},
                    {field: 'repair', title: '维护状态', align: 'center',width:'100',templet:function(d){
                        if(d.repair == "未维护"){
                            return '<font style="color:red">'+d.repair+'</font>';
                        }else{
                            return '<font style="color:green">'+d.repair+'</font>';
                        }
                        }},
/*
                    {field: 'way', title: '方式', align: 'center',width:'88'},
*/
                    {field: 'produceplace', title: '器材产地', align: 'center',width:'88'},
                    {field: 'price', title: '租赁价格', align: 'center',width:'120'},
                    {field: 'description', title: '器材描述', align: 'center',width:'393'},
                    {field: 'num', title: '天数', align: 'center',width:'94'},
                    {field: 'state', title: '订单状态', align: 'center',hide:true,width:'106',templet:function (d) {
                            if(d.state == 1){
                                /*
                                                        $("#update").addClass("layui-btn-disabled").attr("disabled",true);
                                */
                                return '<font color="red">待发货</font>'
                            }else if(d.state == 2){
                                /*
                                                        $("#fahuo").addClass("layui-btn-disabled").attr("disabled",true);
                                */
                                return '<font color="blue">已发货</font>'
                            }else if(d.state == 3){
                                /*         $("#update").addClass("layui-btn-disabled").attr("disabled",true);
                                         $("#fahuo").addClass("layui-btn-disabled").attr("disabled",true);*/
                                return '<font color="green">订单完成</font>'
                            }else if(d.state == 4){
                                return '<font color="green">已租赁</font>'

                            }else if (d.state == 5){
                                return '<font color="red">归还待确认</font>'

                            }else if(d.state == 6){
                                return '<font color="green">已归还</font>'

                            }else if(d.state == 7){
                                return '<font color="blue">退货申请</font>'
                            }else if (d.state == 8){
                                return '<font color="green">已退货</font>'

                            }else if(d.state == 9){
                                return '<font color="red">拒绝退货</font>'
                            };
                        }},
                    {field: 'username', title: '购买人', align: 'center',width:'100'},
                    {fixed: 'right', title: '操作', align: 'center',width:'180',templet:'#repairBar'}
                ] ],
                done: function (data, curr, count) {
                    if (username.indexOf("管理员")==-1  ) {
                        $("[data-field='username']").css('display', 'none'); //关键代码
                    }
                    //不是第一页时，如果当前返回的数据为0那么就返回上一页
                    if (data.data.length == 0 && curr != 1) {
                        tableIns.reload({
                            page: {
                                curr: curr - 1
                            }
                        })
                    }
                }
            });
        }else{
            tableIns = table.render({
                elem: "#orderTable",
                title: "订单数据表格",
                url: "/order/loadAllOrder2",
                where:{username:username},
                toolbar: "#orderToolBar",
                page: true,
                height: "full-180",
                cols: [ [
                    {field: 'id', title: 'ID', align: 'center',width:'61'},
                    {field: 'ordernum', title: '订单号', align: 'center',width:'200'},
                    {field: 'goodsname', title: '商品名称', align: 'center',width:'173'},
                    {field: 'way', title: '方式', align: 'center',width:'88'},
                    {field: 'produceplace', title: '商品产地', align: 'center',width:'88'},
                    {field: 'price', title: '销售/租赁价格', align: 'center',width:'120'},
                    {field: 'description', title: '商品描述', align: 'center',width:'393'},
                    {field: 'num', title: '数量/天数', align: 'center',width:'94'},
                    {field: 'state', title: '订单状态', align: 'center',width:'106',templet:function (d) {
                            if(d.state == 1){
                                /*
                                                        $("#update").addClass("layui-btn-disabled").attr("disabled",true);
                                */
                                return '<font color="red">待发货</font>'
                            }else if(d.state == 2){
                                /*
                                                        $("#fahuo").addClass("layui-btn-disabled").attr("disabled",true);
                                */
                                return '<font color="blue">已发货</font>'
                            }else if(d.state == 3){
                                /*         $("#update").addClass("layui-btn-disabled").attr("disabled",true);
                                         $("#fahuo").addClass("layui-btn-disabled").attr("disabled",true);*/
                                return '<font color="green">订单完成</font>'
                            }else if(d.state == 4){
                                return '<font color="green">已租赁</font>'

                            }else if (d.state == 5){
                                return '<font color="red">归还待确认</font>'

                            }else if(d.state == 6){
                                return '<font color="green">已归还</font>'

                            }else if(d.state == 7){
                                return '<font color="blue">退货申请</font>'
                            }else if (d.state == 8){
                                return '<font color="green">已退货</font>'

                            }else if(d.state == 9){
                                return '<font color="red">拒绝退货</font>'
                            };
                        }},
                    {field: 'username', title: '购买人', align: 'center',width:'100'},
                    {fixed: 'right', title: '操作', align: 'center',width:'180',templet:'#classActionBar'}
                ] ],
                done: function (data, curr, count) {
                    if (username.indexOf("管理员")==-1  ) {
                        $("[data-field='username']").css('display', 'none'); //关键代码
                    }
                    //不是第一页时，如果当前返回的数据为0那么就返回上一页
                    if (data.data.length == 0 && curr != 1) {
                        tableIns.reload({
                            page: {
                                curr: curr - 1
                            }
                        })
                    }
                }
            });
        }
        //初始化表格 加载数据


      /*  //初始化查询条件的下拉列表
        $.get("/provider/loadAllProviderForSelect",function (res) {
            var data = res.data;
            var dom = $("#select_providerid");
            var html = '<option value="0">请选择供应商</option>';
            $.each(data,function (index, item) {
                html += '<option value="'+item.id+'">'+item.providername+'</option>';
            })
            dom.html(html);
            //重新渲染下拉列表
            form.render("select");
        });*/

        //监控模糊查询按钮事件
        form.on("submit(doSearch)", function (data) {
            tableIns.reload({
                where: data.field,
                page: {
                    curr: 1
                }
            });
            return false;
        });

        table.on("toolbar(orderTable)", function (obj) {
            switch (obj.event) {
                case 'add':
                    openAddLayer();
                    break;
            }

        });


        //监控行工具条事件
        table.on("tool(orderTable)", function (obj) {
            //获取当前行数据
            var data = obj.data;
            switch (obj.event) {
                case 'delete':
                    deleteGoods(data);
                    break;
                case 'Update':
                    updateGoods(data);
                    break;
                case 'update':

                    abc(data);
                    break;
                case 'fahuo':

                    fahuoGoods(data);
                    break;
                case 'tuihuo':

                    tuihuoGoods(data);
                    break;
                case 'return':
                    returnGoods(data);
                    break;
               case 'confirmReturn':
                    confirmReturn(data);
                    break;
                case 'repair':
                    repair(data);
                    break;
            }
        });

        //文件上传
/*        upload.render({
            elem: '.thumbBox',
            url: '/file/uploadFile',
            acceptMime:'image/!*',
            field:'mf',
            method : "post",
            done: function(res, index, upload){
                var path=res.path;
                $('.thumbImg').attr('src','/file/showImageByPath?path='+path);
                $('.thumbBox').css("background","#fff");
                //给隐藏域赋值
                $("#goodsimg").val(path);
            }
        });*/

        var mainIndex;
        var url;


        //打开添加弹出层
        function openAddLayer() {
            mainIndex = layer.open({
                type:1,
                content:$("#addOrUpdateDiv"),
                area:['700px','350px'],
                title:'添加订单',
                success:function () {
                    $("#dataFrm")[0].reset();
                    url="/order/addOrder";
                }
            });
        }

        //打开修改的弹出层
        function updateGoods(data) {
            mainIndex = layer.open({
                type:1,
                content:$("#addOrUpdateDiv"),
                area:['700px','350px'],
                title:'修改商品',
                success:function () {
                    //清空原有的数据
                    $("#dataFrm")[0].reset();
                    //装载新的数据
                    form.val("dataFrm",data);
                    form.render("select");
                    url="/order/updateOrder";
                }
            });
        }

        form.on("submit(doSubmit)",function (data) {
            $.post(url,data.field,function (res) {
                if (res.code==200){
                    tableIns.reload();
                }
                layer.msg(res.msg);
                layer.close(mainIndex);
            });
            return false;
        });

        //queren
        function abc(data) {
            console.log("2");
            layer.confirm('你确定要已经收到【' + data.goodsname + '】这个商品吗？', {icon: 3, title: '提示'}, function (index) {
                $.post("/order/confirmGet", {id:data.id},function (res) {
                    if (res.code == 200) {
                        tableIns.reload({
                            where:"",
                        });
                    }
                    layer.msg("订单完成！");
                });
                layer.close(index);
            });
        }
        //删除
        function deleteGoods(data) {
            layer.confirm('你确定要删除这个订单吗？', {icon: 3, title: '提示'}, function (index) {
                $.post("/order/deleteOrder/"+data.id,function (res) {
                    if (res.code == 200) {
                        tableIns.reload({
                            where:"",
                        });
                    }
                    layer.msg(res.msg);
                });
                layer.close(index);
            });
        }

        function repair(data){
            layer.confirm('你确定【' + data.goodsname + '】维护完毕了吗？', {icon: 3, title: '提示'}, function (index) {
                $.post("/order/repair", {id:data.id},function (res) {
                    if (res.code == 200) {
                        tableIns.reload({
                            where:"",
                        });
                    }
                    layer.msg("已完成！");
                });
                layer.close(index);
            });
        }
        function fahuoGoods(data) {
            layer.confirm('你确定此商品【' + data.goodsname + '】已经发货了吗？', {icon: 3, title: '提示'}, function (index) {
                $.post("/order/fahuo", {id:data.id},function (res) {
                    if (res.code == 200) {
                        tableIns.reload({
                            where:"",
                        });
                    }
                    layer.msg("已发货！");
                });
                layer.close(index);
            });
        }

        function tuihuoGoods(data) {
            var data1;


            layer.confirm('你确定此订单【' + data.goodsname+"*"+data.num + '】要退货吗？', {icon: 3, title: '提示'}, function (index) {

                data.state = 7;
                $.post("/order/updateOrder", data,function (res) {

                });
                data.number = data.num;
                $.post("/salesback/addSalesback", data,function (res) {
                    if (res.code == 200) {
                        tableIns.reload({
                            where:"",
                        });
                    }
                    layer.msg("已申请！");
                });
                layer.close(index);
            });
        }



        function returnGoods(data) {
            layer.confirm('你确定【' + data.goodsname + '】发送归还申请吗？', {icon: 3, title: '提示'}, function (index) {
                $.post("/order/return", {id:data.id},function (res) {
                    if (res.code == 200) {
                        tableIns.reload({
                            where:"",
                        });
                    }
                    layer.msg("已发送！");
                });
                layer.close(index);
            });
        }
        function confirmReturn(data) {
            layer.confirm('你确定此商品【' + data.goodsname + '】已经归还了吗？', {icon: 3, title: '提示'}, function (index) {
                $.post("/order/confirmReturn", {id:data.id},function (res) {
                    if (res.code == 200) {
                        tableIns.reload({
                            where:"",
                        });
                    }
                    layer.msg("订单完成！");
                });
                layer.close(index);
            });
        }

    });


</script>

</body>
</html>